from coin.exchange.base.kr_rest.py_product import PyProduct
from coin.exchange.base.kr_rest.product_info import (
    ProductHolder, ProductInfoConstant)
from coin.exchange.huobi.kr_rest.product_info import huobi_product_info
from coin.exchange.huobi_futures_swap.kr_rest.constants import swap_pi_file, linear_swap_pi_file
from coin.exchange.huobi_futures.kr_rest.futures_product import HuobiFuturesProduct

huobi_futures_swap_product_info = ProductInfoConstant(swap_pi_file)
huobi_futures_linear_swap_product_info = ProductInfoConstant(linear_swap_pi_file)

def get_holder_from_product(product):
  if isinstance(product, PyProduct):
    assert product.market_name == 'Futures' and product.exchange_name == 'Huobi'
  else:
    assert isinstance(product, HuobiFuturesProduct)
  product_info = huobi_product_info.get_product_info(product.relative_norm)
  return ProductHolder(product, product_info)
